package test.test_7_6;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

/*

 */
public class Demo04 {
    public static void main(String[] args) throws ParseException {
        extracted();

    }

    private static void extracted() throws ParseException {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你的生日 格式为1980-01-01");
        String birthDataStr= scanner.nextLine();
        //将日期字符串转换成日期对象
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date date = simpleDateFormat.parse(birthDataStr);
        //获取生日日期对象对应的毫秒值
        long brithdayTime = date.getTime();
        //获取系统当前对应的毫秒值
        long currentTime = System.currentTimeMillis();
        long time = (currentTime - brithdayTime) / (1000 * 60 * 60 * 24);
        System.out.println("你来到这个世界"+time+"天");
    }

}
